# -*- coding: utf-8 -*-
''''
进行mysql数据操作
'''
import MySQLdb
conn = MySQLdb.connect(
    host = '120.26.85.119',
    port = 3307,
    user = 'root',
    passwd = '042011_cyq',
    db = 'dev_zf',
    charset = 'utf8'
)
cursor = conn.cursor();
print conn;
sql = 'select * from user'
cursor.execute(sql);
print cursor.rowcount
rs = cursor.fetchone();
print rs
rs = cursor.fetchmany(3)
print rs
rs = cursor.fetchall();
print rs
#插入，修改，删除要加上事务conn.commit()
try:
    sql_update = "update user set phone = '17682340292xxxxxxx       ,,,,,,,,,,,,,nnnnnnnnnnnnnnnnnnn' where userSeq = 3"
   #sql_delete = "delete from user where userSeq = 4"
    #cursor.execute(sql_delete)
    cursor.execute(sql_update)
    print  cursor.rowcount
    conn.commit();
except Exception as e:
    conn.rollback();
    print e
cursor.close();
conn.close();

